
<script type="text/javascript" src="catalog/view/javascript/jquery.cascade.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery.cascade.ext.js"></script>
<script type="text/javascript" src="catalog/view/javascript/jquery.templating.js"></script>


<div class="box">
  <div class="top"><?php echo $heading_title; ?></div>
  <div id="ymm_search" class="middle" style="text-align: left;">
  <b>Make:</b>
    <select id="carmake" style="width:140px" >
      <option value=""><?php echo $text_select; ?></option>
      <?php foreach ($ymms as $ymm) { ?>
      <?php if ($ymm['ymm_id'] == $ymm_id) { ?>
      <option value="<?php echo $ymm['ymm_id']; ?>" selected="selected"><?php echo $ymm['name']; ?></option>
      <?php } else { ?>
      <option value="<?php echo $ymm['ymm_id']; ?>"><?php echo $ymm['name']; ?></option>
      <?php } ?>
      <?php } ?>
    </select>
	
	
<BR>
 <b>Model:</b>
<select id="carmodel" style="width:140px" >

<option value=""> <?php echo $text_select; ?> </option>

</select>

<BR>
 <b>Year:</b>
<select id="caryear" style="width:140px" >

<option value=""> <?php echo $text_select; ?> </option>

</select>

<script type="text/javascript">


$(function () {

// 

$('#carmodel').cascade('#carmake', {

ajax: {

type: "post",

url: 'action.php',

data: { act: 'first', val: $('#carmake').val() },

dataType: "json"

},

template: function(item) { return "<option value='" + item.Value + "'>" + item.Text + "</option>"; },

match: function(selectedValue) { return this.When == selectedValue; }

});

// 

$('#caryear').cascade('#carmodel', {

ajax: {

type: "post",

url: 'action.php',

data: { act: 'second', val: $('#carmodel').val() },

dataType: "json"

},

template: function(item) { return "<option value='" + item.Value + "'>" + item.Text + "</option>"; },

match: function(selectedValue) { return this.When == selectedValue; }

});

});

</script>
  </div>
  
 <div class="buttons">
      <table>
        <tr>
          <td align="right"><a onclick="ymm();" class="button"><span>Search</span></a></td>
        </tr>
      </table>
    </div>
</div>
<script type="text/javascript"><!--

function ymm() {
	url = 'index.php?route=product/ymm';
	
	

	var carmake_id = $('#carmake').attr('value');
	
	if (carmake_id) {
		url += '&carmake_id=' + encodeURIComponent(carmake_id);
	}
	
	var carmodel_id = $('#carmodel').attr('value');
	
	if (carmodel_id) {
		url += '&carmodel_id=' + encodeURIComponent(carmodel_id);
	}
	
	var caryear_id = $('#caryear').attr('value');
	
	if (caryear_id) {
		url += '&caryear_id=' + encodeURIComponent(caryear_id);
	}
	
	
	
	location = url;
}
</script>
